package com.project.restaurant.order.dao;

import com.project.restaurant.order.dto.OrderItem;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderItemDao {

    @Results(id = "OrderItemResultMap",value = {
            @Result(column = "meal_id",property = "mealItem",
                    one = @One(select = "com.project.restaurant.order.dao.MealItemDao.selectById"))
    })
    @Select("select oi.item_id,oi.meal_id,oi.purchasing_meal_price,oi.purchase_num " +
            "from r_order_detail_item oi where item_id = #{itemId}")
    OrderItem selectById(int itemId);

    @ResultMap("OrderItemResultMap")
    @Select("select oi.item_id,oi.meal_id,oi.purchasing_meal_price,oi.purchase_num " +
            "from r_order_detail_item oi where order_id = #{orderId}")
    List<OrderItem> selectByOrderId(String orderId);
}
